﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Model
{
    public class Product
    {
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        public int Id { get; set; }
        public string Name { get; set; }
        public string CharacterCode {  get; set; }
        public int Length {  get; set; }

        public int CCodeLength {  get; set; }

        public int CCodeLocation {  get; set; }

        public bool IsTask {  get; set; }

        public bool IsLoad {  get; set; }

        public bool IsReport {  get; set; }

        public bool IsUpdata {  get; set; }

        public string EquipmentCode {  get; set; }
        public int UserId {  get; set; }    

        public string MaterialCode {  get; set; }

        public Product()
        {
            Name = string.Empty;
            CharacterCode = string.Empty;
        }
        /// <summary>
        /// 检查code是否符合特征要求
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public bool Check(string code)
        {
            if(code.Length ==Length && code.Substring(CCodeLocation,CCodeLength) == CharacterCode)
                return true;
            return false;
        }
    }
}
